package LCR;

public class isSymmetric {
    boolean cur = true;
    public boolean isSymmetric(TreeNode root) {
        if(root.left == null && root.right == null) {
            return true;
        }
        recur(root.left,root.right);
        return cur;
    }
    boolean recur(TreeNode left,TreeNode right) {
        if(cur == false) {
            return false;
        }
        if(left == null && right == null) {
            return true;
        }
        if(left == null && right != null) {
            cur = false;
            return false;
        }
        if(left != null && right == null) {
            cur = false;
            return false;
        }

        if(left.val != right.val) {
            cur = false;
            return false;
        }
        recur(left.left,right.right);
        recur(left.right,right.left);
        return true;



    }
}
